package com.rr.learningdemo.structure;

/**
 * @author RR
 * @date 2021/3/13 14:21
 */
public class StringDemo {
    /*
    * s1.equals(s2)方法
    * 先查看s1 == s2，如果相等直接返回true
    * 判断s2是否是String,不是直接返回false
    * 获取s1和s2的char[]
    * 逐个比较数组的char，如果出现不同字符则返回false
    * 查检都通过返回true
    * */
    public static void main(String[] args) {
        String s1 = "str";
        String s2 = new String("str");
        String s3 = "str";

        System.out.println("s1 == s2:" + (s1 == s2));
        System.out.println("s1 equals s2:" + s1.equals(s2));
        System.out.println("s1 == s3:" + (s1 == s3));
    }
}
